window.onload = function(){load();}

function load(){
    var str = window.location.href;
    //str.split('/');
    var a = /\d+/.exec(str);
    //var a = str.split(/apply\//);
    //var a = str[str.length-1];
    //$("#controOne").append("<p>"+ a +"</p>"+"<br>");
    getAllpy(a);
}

function getAllpy(k){
    $("#controOne").html("");
     $.get(
        "http://localhost/registration_system/main/showApply/"+k,
            function(data){
            var arr = new Array();
            arr = JSON.parse(data);
            //console.log(arr);
            for (var i = 0; i <= arr.apply.length; i++)
            {

            	$("#controOne").append("<p>"+(i+1)+"."+arr.apply[i].vcQues+"</p>"+"<br>");
            	if(arr.apply[i].iType == "text")//显示填空题
            	{
            		$("#controOne").append("<input type='text' name='"+arr.apply[i].iQuizNo
                            + "'>"+"</input>"+"<br>");
            	}
            	if(arr.apply[i].iType == "radio")//显示单选题
            	{
            		if(arr.apply[i].vcAns1!=null)
            		{
            			$("#controOne").append("<input type='radio' name='"+arr.apply[i].iQuizNo
                            + "' value='"+arr.apply[i].vcAns2+"'>"+arr.apply[i].vcAns1+"<br>");
            		}
            		if(arr.apply[i].vcAns2!=null)
            		{
            			$("#controOne").append("<input type='radio' name='"+arr.apply[i].iQuizNo
                            + "' value='"+arr.apply[i].vcAns2+"'>"+arr.apply[i].vcAns2+"<br>");
            		}
            		if(arr.apply[i].vcAns3!=null)
            		{
            			$("#controOne").append("<input type='radio' name='"+arr.apply[i].iQuizNo
                            + "' value='"+arr.apply[i].vcAns3+"'>"+arr.apply[i].vcAns3+"</input>"+"<br>");
                    }
            		if(arr.apply[i].vcAns4!=null)
            		{
            			$("#controOne").append("<input type='radio' name='"+arr.apply[i].iQuizNo
                            + "' value='"+arr.apply[i].vcAns4+"'>"+arr.apply[i].vcAns4+"</input>"+"<br>");
            		}
            		
            	}
            	if(arr.apply[i].iType=="check")//显示多选题
            	{
            		if(arr.apply[i].vcAns1!=null)
            		{
            			$("#controOne").append("<input type='checkbox' name='"+arr.apply[i].iQuizNo
                            + "[1]' value='1'>"+arr.apply[i].vcAns1+"</input>"+"<br>");
            		}
            		if(arr.apply[i].vcAns2!=null)
            		{
            			$("#controOne").append("<input type='checkbox' name='"+arr.apply[i].iQuizNo
                           +"[2]' value='2'>"+arr.apply[i].vcAns2+"</input>"+"<br>");
            		}
            		if(arr.apply[i].vcAns3!=null)
            		{
            			$("#controOne").append("<input type='checkbox' name='"+arr.apply[i].iQuizNo
                            +"[3]' value='3'>"+arr.apply[i].vcAns3+"</input>"+"<br>");
            		}
            		if(arr.apply[i].vcAns4!=null)
            		{
            			$("#controOne").append("<input type='checkbox' name='"+arr.apply[i].iQuizNo
                            +"[4]' value='4'>"+arr.apply[i].vcAns4+"</input>"+"<br>");
            		}
            	}	
            }
            }
)};


function upload(){
    return true;
}